require "aio"

port = "/dev/ttyUSB0"

puts "Press Control+C to cancel..."

Aio::Board.new(port) do |board|
	loop do
		begin
			if time = board.millis
				puts "Time: #{time} ms"
			else
				# To trigger this, hit the reset button.
				puts "Command error. Trying again..."
			end
		rescue Aio::DeviceError
			puts "Connection error. Doing safe exit..."
			break
		end
		sleep 0.5
	end
end
